package com.viphuli.http.handler;

import android.view.View;

import com.viphuli.app.R;
import com.viphuli.common.MyPageHelper;
import com.viphuli.fragment.AccountFragment;
import com.viphuli.http.bean.page.AccountPage;
import com.viphuli.http.bean.part.AccountUser;

public class AccountResponseHandler extends MyBaseHttpResponseHandler<AccountFragment, AccountPage> {

	@Override
	public void deal() {
		AccountUser user = page.getUser();

		if (user != null) {

			caller.setUser(user);

			caller.getUserNameView().setVisibility(View.VISIBLE);
			caller.getTicketCountView().setVisibility(View.VISIBLE);

			caller.getUserNameView().setText(String.valueOf(user.getTel()));
			caller.getTicketCountView().setText(user.getConsumeTicketCount() + "张");

			//			//控制护士加入显示
			//			if (user.getUserType() == UserType.nurse.getValue()) {
			//				caller.getInviteLayout().setVisibility(View.GONE);
			//			} else {
			//				caller.getInviteLayout().setVisibility(View.VISIBLE);
			//			}

		} else {
			caller.setUser(null);
			caller.getTicketCountView().setVisibility(View.GONE);
			caller.getUserNameView().setVisibility(View.VISIBLE);

			caller.getUserNameView().setText(caller.getString(R.string.str_account_bind_phone));

			caller.getUserNameView().setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View view) {

					if (!caller.isAdded())
						return;

					MyPageHelper.accountLogin.showMyPage(caller.getActivity());
				}
			});

		}
	}

}
